<?php

function smarty_function_select_last_topic_by_uid($params, &$smarty) {
    $uid = $params['uid'];
    if($uid){
      $sql = "SELECT tpc_id,tpc_type_id,tpc_title,tpc_price,tpc_firstimage,tpc_firsthumbimage 
              FROM zk_innoforum_topics
              WHERE tpc_cr_uid  = ".$uid."
              ORDER BY tpc_temp_cr_date  DESC 
              LIMIT 0, 1";

      $column = array("id","type_id","title","price","image","thumb");
      $result = DBUtil::executeSQL($sql);
      $objectArray = DBUtil::marshallObjects ($result, $column);
      $value['id'] = $objectArray['0']['id'];
      $value['type_id'] = $objectArray['0']['type_id'];
      $value['title'] = $objectArray['0']['title'];
      $value['price'] = $objectArray['0']['price'];
      $value['image'] = $objectArray['0']['image'];
      $value['thumb'] = $objectArray['0']['thumb'];

      if(!empty($value)){
        $smarty->assign("topic", $value);
      }
    }
}
